package com.game.dongzhao.view;

import com.game.dongzhao.DongZhaoApplication;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.text.Font;
import javafx.scene.text.Text;

import java.io.IOException;

import static com.game.dongzhao.DongZhaoApplication.logger;

/**
 * 事件处理函数模板
 */
public class StartView {
    @FXML
    private TextArea gameInfo;

    @FXML
    private Text gameName;

    @FXML
    private Button startBtn;

    @FXML
    private Button showGameInfoBtn;

    @FXML
    private Button closeInfoBtn;

    /**
     * 关闭游戏说明
     *
     * @param event
     */
    @FXML
    void closeInfo(ActionEvent event) {
        logger.log(System.Logger.Level.INFO,"closeInfoBtn按下");
        this.gameInfo.setVisible(false);
        this.closeInfoBtn.setVisible(false);
    }

    /**
     * 显示游戏说明
     *
     * @param event
     */
    @FXML
    void showGameInfo(ActionEvent event) {
        logger.log(System.Logger.Level.INFO,"showGameInfoBtn按下");
        // this.gameInfo.setFont(new Font(15.0));
        this.gameInfo.setVisible(true);
        this.closeInfoBtn.setVisible(true);
    }

    /**
     * 开始游戏 所有数据与画面的载入和初始化 转入界面
     *
     * @param event
     */
    @FXML
    void startGame(ActionEvent event) {
        try {
            logger.log(System.Logger.Level.INFO,"startBtn按下");
            new DongZhaoApplication().changeView("主游戏界面","main-view.fxml");
        } catch (IOException e) {
            logger.log(System.Logger.Level.ERROR,"开始游戏失败");
            e.printStackTrace();
        }
    }
}
